using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy_Skeleton : Enemy
{
    public CapsuleCollider2D cd;
	#region States
	public SkeletonIdleState idleState { get; private set; }
	public SkeletonMoveState moveState { get; private set; }
	public SkeletonBattleState battleState { get; private set; }
	public SkeletonAttackState attackState { get; private set; }
    public SkeletonBeHitedState beHitedState { get; private set; }
    public SkeletonDeadState deadState { get; private set; }
    #endregion

    protected override void Awake()
    {
        base.Awake();

		#region InstantiationState
		idleState = new SkeletonIdleState(this, stateMachine, "Idle", this);
		moveState = new SkeletonMoveState(this, stateMachine, "Move", this);
		battleState = new SkeletonBattleState(this, stateMachine, "Move", this);
		attackState = new SkeletonAttackState(this, stateMachine, "Attack", this);
        beHitedState = new SkeletonBeHitedState(this, stateMachine, "BeHited", this);
        deadState = new SkeletonDeadState(this, stateMachine, "Dead", this);
		#endregion
	}

    protected override void Start()
    {
        base.Start();

        cd = GetComponent<CapsuleCollider2D>();

		stateMachine.Initalize(idleState);
    }

    protected override void Update()
    {
        base.Update();

        if(PlayerManager.instance.player.currentWeapon != null)
        { 
            if (impactResistance < PlayerManager.instance.player.currentWeapon.baseImpact && isKnocked && !isDead)
                stateMachine.ChangeState(beHitedState);
        }
    }

    public override void Die()
    {
        base.Die();
        isDead = true;
        stateMachine.ChangeState(deadState);
    }
}
